var errorContainer;
var controlContainer;
function ManagementUser(errorcontainer,controlcontainer){
    errorContainer=errorcontainer;
    controlContainer=controlcontainer;
}
ManagementUser.prototype.toggleActivation=function(uid){
    var xmlhttp;
    var data="action=USER_ACTIVATION&userid="+uid;
    xmlhttp=getXmlHttpObj();
    xmlhttp.open("GET",contextPath+"/UserController?"+data,true);
    xmlhttp.send();
    xmlhttp.onreadystatechange=function(e){
        var current=e.target;
        if (current.readyState==4 && current.status==200)
        {
            var errorXml=xmlhttp.responseXML;
            errorContainer.innerHTML="";
    
            if(errorXml){
                errorContainer.innerHTML=xmlhttp.responseXML.getElementsByTagName("error")[0].textContent.fontcolor("red");
            }else{
                var resString=xmlhttp.responseText;
                controlContainer.innerHTML=resString;
            }
        }
    }
}
ManagementUser.prototype.updateRole=function(uid,roleid){
   var xmlhttp;
    var data="action=USER_ROLE_UPDATE&roleid="+roleid+"&userid="+uid;
    xmlhttp=getXmlHttpObj();
    xmlhttp.open("GET",contextPath+"/UserController?"+data,true);
    xmlhttp.send();
    xmlhttp.onreadystatechange=function(e){
        var current=e.target;
        if (current.readyState==4 && current.status==200)
        {
            var errorXml=xmlhttp.responseXML;
            errorContainer.innerHTML="";
    
            if(errorXml){
                errorContainer.innerHTML=xmlhttp.responseXML.getElementsByTagName("error")[0].textContent.fontcolor("red");
            }else{
                var resString=xmlhttp.responseText;
                controlContainer.innerHTML=resString;
            }
        }
    }
}
ManagementUser.prototype.viewUserDetail=function(uid){
    var btnClose = document.getElementById("btnClose");
    var container =  document.getElementById("PopupContainer");
    var content = document.getElementById("content");
    var overlay = document.getElementById("fadeOverlay");
    var uString = loadUserDetailView(uid);
    content.innerHTML=uString;
    var popupUserDetail = new Lightbox(btnClose, overlay, container, content);
    popupUserDetail.show();
}
function loadUserDetailView(uid){
    var xmlhttp;
    var data="action=TRANSFORM_USER_DETAIL&userdetailid=" + uid;
    xmlhttp=getXmlHttpObj();
    xmlhttp.open("GET", contextPath+"/FlowController?"+data, false);
    xmlhttp.send();
    return xmlhttp.responseText;
}